package cog.support.mybatis.generator.util;

/**
 * Created by Administrator on 2016/8/23 0023.
 */
public class StringKit {
    /**
     * 首字母大写
     *
     * @param srcStr
     * @return
     */
    public static String firstCharacterToUpper(String srcStr) {
        return srcStr.substring(0, 1).toUpperCase() + srcStr.substring(1);
    }

    /**
     * 替换字符串并让它的下一个字母为大写
     *
     * @param srcStr
     * @param substr
     * @return String
     */
    public static String replaceUnderlineAndfirstToUpper(String srcStr, String substr, boolean firstUp) {
        StringBuilder returnStr = new StringBuilder();
        String[] str = srcStr.split(substr);
        for (int index = 0; index < str.length; index++) {
            String s = str[index];
            if (index == 0 && !firstUp) {
                returnStr.append(s);
            } else {
                returnStr.append(firstCharacterToUpper(s));
            }
        }
        return returnStr.toString();
    }
}
